package flc.ast.adapter;

import android.graphics.Color;
import android.graphics.Paint;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.bean.StkResBean;

public class TagRankAdapter extends StkProviderMultiAdapter<StkResBean> {

    public TagRankAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new TagRankProvider());
    }

    private class TagRankProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_tag_rank;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
            baseViewHolder.setText(R.id.tvTagRankItemName, bean.getName());
            TextView textView = baseViewHolder.getView(R.id.tvTagRankItemName);
            textView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);

            if (baseViewHolder.getBindingAdapterPosition() == 0) {
                baseViewHolder.setTextColor(R.id.tvTagRankItemNum, Color.parseColor("#ED3266"));
            } else if (baseViewHolder.getBindingAdapterPosition() == 1) {
                baseViewHolder.setTextColor(R.id.tvTagRankItemNum, Color.parseColor("#F18314"));
            } else if (baseViewHolder.getBindingAdapterPosition() == 2) {
                baseViewHolder.setTextColor(R.id.tvTagRankItemNum, Color.parseColor("#FFD126"));
            } else {
                baseViewHolder.setTextColor(R.id.tvTagRankItemNum, Color.parseColor("#585A5E"));
            }
            baseViewHolder.setText(R.id.tvTagRankItemNum, (baseViewHolder.getBindingAdapterPosition() + 1) + "");
        }
    }

}
